<?php
class package_model extends jqxGrid_CI_Model {

    function __construct()
    {
        parent::__construct();
        
    }
    
    function get($_id){
        $where=array('ID'=>$_id);
        $query=$this->db->get_where("dtb_package", $where); 
        return $query->result();
    }
    function gets(){
        $where=array('Delete'=>NULL);
        $query=$this->db
                ->where($where)
                ->get("dtb_package"); 
        return $query->result();
    }
    function insert($params){
        $this->db->set('Insert', 'NOW()', FALSE);
        $this->db->insert("dtb_package", $params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    function delete($_id){
        $this->db->set('Delete', 'NOW()', FALSE);
        $where=array('ID'=>$_id);
        $this->db->where($where);
        $this->db->update("dtb_package"); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return $count;
        return false;
    }
    function retore($_id){
        $this->db->set('Delete', 'NULL', FALSE);
        $where=array('ID'=>$_id);
        $this->db->where($where);
        $this->db->update("dtb_package"); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return $count;
        return false;
    }
    function update($_id,$params){
        $this->db->set('Update', 'NOW()', FALSE);
        $this->db->where('ID', $_id);
        $this->db->update("dtb_package", $params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return $count;
        return false;
    }
    function binding(){
        $strQuery="
            SELECT SQL_CALC_FOUND_ROWS `dtb_package`.*
            FROM `dtb_package`
            ";
        $strWhere="
            WHERE  true
            ";
        if($_SESSION["ADP"][CCTRL]["display"]==0){
            $strWhere.=" AND `dtb_package`.`Delete` IS NULL";
        }elseif($_SESSION["ADP"][CCTRL]["display"]==-1){
            $strWhere.=" AND `dtb_package`.`Delete` IS NOT NULL";
        }
        $strOrderBy="Order By `dtb_package`.`Insert` DESC ";
        $strGroupBy="";
        $config=array(
            "strQuery"=>$strQuery,
            "strWhere"=>$strWhere,
            "strOrderBy"=>$strOrderBy,
            "strGroupBy"=>$strGroupBy,
            "usingLimit"=>false,
            "fields"=>array(
                
            ),
            "datefields"=>array()
        );
        $this->init($config);
        return $this->jqxBinding();
    }
}
?>
